package com.pro.service.imple;

import com.pro.mapper.JsLoginRecordMapper;
import com.pro.mapper.JsUserMapper;
import com.pro.pojo.JsLoginRecord;
import com.pro.pojo.JsUser;
import com.pro.pojo.JsonData;
import com.pro.service.JsLoginRecordService;
import com.pro.service.JsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * @author MYH - SiYun
 * @date 2022/1/6 18:49
 */

@Service
public class JsLoginRecordServiceImple implements JsLoginRecordService {

    @Autowired
    private JsLoginRecordMapper jsLoginRecordMapper;

    @Override
    public boolean getJsUserJsLoginRecord(JsLoginRecord jsLoginRecord) {
        return jsLoginRecordMapper.getJsUserJsLoginRecord(jsLoginRecord);
    }

    @Override
    public List<JsLoginRecord> getAllJsLoginRecord() {
        return jsLoginRecordMapper.getAllJsLoginRecord();
    }
    /**
     * @Author 祖铭泽
     * @Date 2022/1/20/0020
     * @description 查询用户最后一次登陆时间
     */
    @Override
    public JsonData getLastLoginTimeByUserId(Integer userId) {
        String lastLogin = jsLoginRecordMapper.getLastLoginTimeByUserId(userId);
        return lastLogin != null ? JsonData.buildSuccess(lastLogin) : JsonData.buildError("获取失败");
    }
}
